//
//  MyAttendanceVC.m
//  SchoolTask
//
//  Created by feel on 16/8/25.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "MyAttendanceVC.h"
#import "MyAttendance.h"
#import "MyAttendanceCell.h"
#import "ClassAttendanceVC.h"
#import "SignModel.h"
#import "MyAttendanceModel.h"

@interface MyAttendanceVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,retain) UITableView *tableView;
@property (nonatomic,retain) SignModel   *singMode;
@property (nonatomic,retain) NSString *urlStr;
@property (nonatomic,retain) NSDictionary *urlParameters;
@end

@implementation MyAttendanceVC

- (SignModel *)singMode{
    
    if (!_singMode) {
        
        _singMode = [[SignModel alloc]init];
    }
    return _singMode;
}
//请求数据
- (void)fecthDataFromNet:(NSString *)url parameters:(NSDictionary *)parameter {
    
    NSLog(@"%@",url);
    NSLog(@"%@",parameter);
    //初始化请求工具
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:url parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
//                NSLog(@"MyAttendanceVC--登录-%@",dic[@"message"]);
//                NSLog(@"MyAttendanceVC-%@",dic);
        
        [self.singMode setValuesForKeysWithDictionary:dic[@"info"]];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        
        
    }];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _urlStr = @"http://www.100xsys.com.cn/school/app/signInfo/listJson";
    _urlParameters = [[NSDictionary alloc]initWithObjectsAndKeys:@"1",@"appWebConfigId",@"1",@"page",@"10",@"rows",@"校园公告",@"noticeInfo. noticeTypeCode",@"1",@"noticeInfo.recommend", nil];
    [self fecthDataFromNet:_urlStr parameters:_urlParameters];
    CGRect rect = [UIScreen mainScreen].bounds;
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 202, rect.size.width, 500)];
    _tableView.delegate   = self;
    _tableView.dataSource = self;
    [_tableView registerNib:[UINib nibWithNibName:@"MyAttendaceCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
    MyAttendance *select  = [[MyAttendance alloc]init];
    [self.view addSubview:select];
    [self.view addSubview:_tableView];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MyAttendanceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    [cell setCellLabel];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 100;
}




@end
